package com.daikit.commons.shared.exception.utils;


/**
 * Exception message formatting provider. You may statically override {@link #messageFormatter} to provide custom
 * behavior. This approach allows to have GWT client side exceptions working with default message formatter and server
 * side exceptions using custom formatter
 *
 * @author tcaselli
 * @version $Revision$ Last modifier: $Author$ Last commit: $Date$
 */
public class DkExceptionMessageProvider
{

	/**
	 * The formatter that may be overridden at runtime to provide custom server side formatting behavior
	 */
	public static DkMessageFormatter messageFormatter = new DkDefaultMessageFormatter();

	/**
	 * Formats arguments given in placeholders like {0} , {1} ...
	 *
	 * @param code
	 *           the error code
	 * @param toFormat
	 *           the string to format that can contain placeholders for values to be replaced by arguments.
	 * @param arguments
	 *           the arguments to be replaced
	 * @return a formatted string
	 */
	public static String format(final String code, final String toFormat, final Object... arguments)
	{
		return messageFormatter.format(code, toFormat, arguments);
	}

}
